<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>玉林师范学院毕业生档案查询</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,
minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes"/>
    <link rel="stylesheet" href="./css/weui.css"/>
    <link rel="stylesheet" href="./css/weui2.css"/>
</head>
<body>
<?php error_reporting(0);
/**
 * Created by PhpStorm.
 * User: 廖权名<QQ:1528490339>
 * Date: 2017/7/6
 * Time: 19:36
 */

function getNumberByXh($xh)
{

    include_once('./Classes/PHPExcel.php');

    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
//date_default_timezone_set('Europe/London');
    $data = [];

    $PHPExcel = new PHPExcel();
    $filename = '2018.xls';
//如果excel文件后缀名为.xls，导入这个类
    $exts = substr($filename, (strrpos($filename, ".") + 1));
    if ($exts == 'xls') {
        include_once('./Classes/PHPExcel/Reader/Excel5.php');
        $PHPReader = new \PHPExcel_Reader_Excel5();
    } else if ($exts == 'xlsx') {
        include_once('./Classes/PHPExcel/Reader/Excel2007.php');
        $PHPReader = new \PHPExcel_Reader_Excel2007();
    }
//载入文件
    $PHPExcel = $PHPReader->load($filename);
//获取表中的第一个工作表，如果要获取第二个，把0改为1，依次类推

    $currentSheet = $PHPExcel->getSheet(0);
//获取总列数
    $allColumn = $currentSheet->getHighestColumn();
//获取总行数
    $allRow = $currentSheet->getHighestRow();
//循环获取表中的数据，$currentRow表示当前行，从哪行开始读取数据，索引值从0开始
    for ($currentRow = 1; $currentRow <= $allRow; $currentRow++) {
        //从哪列开始，A表示第一列
        for ($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn++) {
            //数据坐标
            $address = $currentColumn . $currentRow;
            //读取到的数据，保存到数组$arr中
            $data[$currentRow][$currentColumn] = $currentSheet->getCell($address)->getValue();
        }
    }

    foreach ($data as $v) {
        if ($v["A"] == $xh) {
//            $number = $v["B"];
//            return $number;
            return [$v["B"],$v["C"]];
        }
    }
    return 0;
}

if (isset($_GET["number"])) {


    $dh = getNumberByXh($_GET["number"]);
    if ($dh == 0) {
        die("查询不到此信息！请核对您输入的信息，确定无误，联系各二级学院负责老师。");
    }

    echo "【" . $dh[0] . "】" . "您好!" . "<p>您的档案快递单号：<span style='background-color: #b587b8 ; border-radius: 5px'>" . $dh[1] . "</span></p>";

    include_once "kd.php";
    $data = getOrderTracesByJson($dh[1]);
    $arr = json_decode($data, true);
    if($arr["Traces"]==null){
        echo "<p style='color: #EF4F4F'>对不起，".($arr["Reason"]) ."</p>";
    };
} else {
    die("不成功");
}
?>




<div class="timeline">
    <ul>
        <?php
        $count = 0;
        foreach (array_reverse($arr["Traces"]) as $item) {
            if ($count == 0)
                echo
                    '<li class="timeline-item"><div class="timeline-item-head-first">
                <i class="weui_icon weui_icon_success_no_circle timeline-item-checked hide"></i></div>
            <div class="timeline-item-tail"></div>
            <div class="timeline-item-content"><h4 class="recent">' . $item["AcceptTime"] . '</h4>
                <p class="recent">' . $item["AcceptStation"] . '</p></div>
        </li>';
            else
                echo
                    '<li class="timeline-item">
            <div class="timeline-item-head"><i
                    class="weui_icon weui_icon_success_no_circle timeline-item-checked hide"></i></div>
            <div class="timeline-item-tail"></div>
            <div class="timeline-item-content"><h4>' . $item["AcceptTime"] . ' </h4>
                <p>' . $item["AcceptStation"] . '</p></div>
        </li>';
            $count++;
        }
        ?>

    </ul>
</div>
<p>结果不理想？点击切换<a href="http://m.kuaidi100.com/result.jsp?nu=<?php echo $dh[1]; ?>">快递100</a>查询</p>

<!--<iframe src="http://www.yiban.cn/school/index/id/5000117" width="100%" height="300px"></iframe>-->

<!--<iframe src="http://m.kuaidi100.com/result.jsp?nu=-->
<?php //echo $dh; ?><!--" width="100%" height="800px"></iframe>-->
</body>
</html>